/**
 * 
 */
 var curTheme='macarons';
    var myChart;
    var domCode = document.getElementById('sidebar-code');
    var domGraphic = document.getElementById('graphic');
    var domMain = document.getElementById('main');
    var domMessage = document.getElementById('wrong-message');
    var iconResize = document.getElementById('icon-resize');
    var needRefresh = false;
    function focusGraphic() {
        domCode.className = 'col-md-4 ani';
        domGraphic.className = 'col-md-8 ani';
        if (needRefresh) {
            myChart.showLoading();
            setTimeout(refresh, 1000);
        }
    }

   function autoResize() {
        if ($(iconResize).hasClass('glyphicon-resize-full')) {
            focusCode();
            iconResize.className = 'glyphicon glyphicon-resize-small';
        }
        else {
            focusGraphic();
            iconResize.className = 'glyphicon glyphicon-resize-full';
        }
    } 

    function refresh(isBtnRefresh){
        if (isBtnRefresh) {
            needRefresh = true;
            focusGraphic();
            return;
        }
        needRefresh = false;
        if (myChart && myChart.dispose) {
            myChart.dispose();
        }
        myChart = echarts.init(domMain, curTheme);
        window.onresize = myChart.resize;
      //  console.log(editor.doc.getValue())
       // (new Function(editor.doc.getValue()))();
        myChart.setOption(option, true)
        domMessage.innerHTML = '';
    }

  /*   function needMap() {
        var href = location.href;
        return href.indexOf('map') != -1
               || href.indexOf('mix3') != -1
               || href.indexOf('mix5') != -1
               || href.indexOf('dataRange') != -1;

    } */

    var echarts;

        // for echarts online home page
    require.config({
        paths: {
            echarts: './js'
        }
    });
        launchExample();
        function requireCallback (ec, defaultTheme) {
         
            echarts = ec;
            refresh();
            window.onresize = myChart.resize;
        }
   
    var isExampleLaunched;
    function launchExample() {
        if (isExampleLaunched) {
            return;
        }

        // 按需加载
        isExampleLaunched = 1;
        require(
            [
                'echarts',
                'theme/macarons', // + hash.replace('-en', ''),
                'echarts/chart/line',
                'echarts/chart/bar',
                'echarts/chart/scatter',
                'echarts/chart/k',
                'echarts/chart/pie',
                'echarts/chart/radar',
                'echarts/chart/force',
                'echarts/chart/chord',
                'echarts/chart/gauge',
                'echarts/chart/funnel',
                'echarts/chart/eventRiver',
                'echarts/chart/venn',
                'echarts/chart/treemap',
                'echarts/chart/tree',
                'echarts/chart/wordCloud',
                'echarts/chart/heatmap',
                //needMap() ? 'echarts/chart/map' : 'echarts'
            ],
            requireCallback
        );
    }